package com.wkbb.common.dto.course;

import com.alibaba.fastjson.annotation.JSONField;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.wkbb.common.handler.JsonUtil;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.models.auth.In;
import lombok.Data;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * 班级信息表
 * b_class_info
 *
 * @author Lxc
 * @date 2019-07-01 13:57:32
 */
@Data
@JsonInclude(JsonInclude.Include.NON_NULL)
public class CourseClassDto implements Serializable {
    @ApiModelProperty(value = "班级名称")
    private String className;
    @ApiModelProperty(value = "编号")
    private Long id;
    @ApiModelProperty(value = "学生报名ID")
    private Long signUpUserId;
    @ApiModelProperty(value = "学校ID")
    private Long orgId;
    @ApiModelProperty(value = "学校")
    private String orgName;
    @ApiModelProperty(value = "班级关联ID")
    private Long classId;
    @ApiModelProperty(value = "班级类型 4课程班 5托管班")
    private Integer classType;
    @ApiModelProperty(value = "服务标识（机构课程uniqueId or 托管uniqueId）")
    private String serviceUniqueId;
    @ApiModelProperty(value = "服务名称")
    private String serviceName;
    @ApiModelProperty(value = "服务封面")
    private String logo;
    @ApiModelProperty("授课方式 1面授 2双师")
    private Integer serviceType;
    @ApiModelProperty("适合年级ID 多个','分割(注：所有年级为`0`)")
    private String gradeIds;
    @ApiModelProperty("适合年级 多个','分割(注：所有年级为`全部`)")
    private String gradeNames;
    @ApiModelProperty("上课时间 多个','分隔")
    private String classTime;
    @ApiModelProperty("最大课时数")
    private Integer maxTimeNum;
    @ApiModelProperty("课程分类id")
    private String tagId;
    @ApiModelProperty("课程分类")
    private String tagName;
    @ApiModelProperty("最大报名人数")
    private Integer maxSignUpNum;
    @ApiModelProperty("报名开始时间")
    private Date signUpStartTime;
    @ApiModelProperty("报名结束时间")
    private Date signUpEndTime;
    @ApiModelProperty("服务开始时间")
    private Date startTime;
    @ApiModelProperty("服务截至时间")
    private Date endTime;
    @ApiModelProperty("已报名数")
    private Integer amount;
    @ApiModelProperty("已报名数")
    private int signUpNum;
    @ApiModelProperty("状态 0未报名 1报名中 2未开课 3开课中 4已结课")
    private Integer status;
    @ApiModelProperty("场地ID")
    private Long siteId;

    @ApiModelProperty("服务年份")
    private String serviceYear;
    @ApiModelProperty("授课老师ID")
    private Long teacherId;
    @ApiModelProperty("授课老师")
    private String teacherName;
    @ApiModelProperty("场地名称")
    private String siteName;

    @ApiModelProperty("创建时间（开班时间）")
    private Date createTime;
    @ApiModelProperty(value = "创建人")
    private String createBy;

    @ApiModelProperty("是否已反馈 1是 0否")
    private Integer haveFeedBack;

    @ApiModelProperty(value = "课时列表")
    private List<CourseTimeDto> courseTimeList;

    public void initStatus() {
        if (signUpStartTime == null || signUpEndTime == null) return;
        long currTime = new Date().getTime();
        if (currTime > signUpEndTime.getTime()) {
            status = 2;
            if (startTime == null || endTime == null) return;
            if (currTime > endTime.getTime()){
                status = 4;
            }else if (currTime > startTime.getTime()){
                status = 3;
            }
            return;
        }
        if (currTime > signUpStartTime.getTime()) {
            status = 1;
            return;
        }
        status = 0;

    }
}